package artid.com.arttogo.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 
*    
* 项目名称：ArtworkArt   
* 类名称：AuctionHomeParser   
* 类描述：拍卖行首页实体类+解析   
* 创建人：耿卫斌   
* 创建时间：2017-3-7 下午5:39:26   
*
 */
public class AuctionHomeParser extends AppItem implements Serializable {
	private static final long serialVersionUID = 1L;
	private List<AuctionHomeAdvs> advs=new ArrayList<AuctionHomeAdvs>();//广告模块
	private List<AuctionHomeLotinfo> lotinfo=new ArrayList<AuctionHomeLotinfo>();//推荐备案拍品
	private List<AuctionHomeSpinfo> spinfo=new ArrayList<AuctionHomeSpinfo>();//推荐专场模块
	@Override
	public void parse(JSONObject obj) {
		// TODO Auto-generated method stub
		JSONArray AdvsArr = obj.optJSONArray("advs");
		for (int i = 0; i < AdvsArr.length(); i++) {
			AuctionHomeAdvs mAuctionHomeAdvs = new AuctionHomeAdvs();
			try {
				mAuctionHomeAdvs.setCat_id(AdvsArr.optJSONObject(i).getString("cat_id"));
				mAuctionHomeAdvs.setImgurl(AdvsArr.optJSONObject(i).getString("imgurl"));
				mAuctionHomeAdvs.setInfo(AdvsArr.optJSONObject(i).getString("info"));
				mAuctionHomeAdvs.setLinkurl(AdvsArr.optJSONObject(i).getString("linkurl"));
				mAuctionHomeAdvs.setTitle(AdvsArr.optJSONObject(i).getString("title"));
				mAuctionHomeAdvs.setType(AdvsArr.optJSONObject(i).getString("type"));
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			advs.add(mAuctionHomeAdvs);
		}
		
		JSONArray LotinfoArr = obj.optJSONArray("lotinfo");
		for (int i = 0; i < LotinfoArr.length(); i++) {
			AuctionHomeLotinfo mAuctionHomeLotinfo= new AuctionHomeLotinfo();
			try {
				mAuctionHomeLotinfo.setImgurl(LotinfoArr.optJSONObject(i).getString("imgurl"));
				mAuctionHomeLotinfo.setIs_record(LotinfoArr.optJSONObject(i).getString("is_record"));
				mAuctionHomeLotinfo.setLot_id(LotinfoArr.optJSONObject(i).getString("lot_id"));
				mAuctionHomeLotinfo.setLot_name(LotinfoArr.optJSONObject(i).getString("lot_name"));
				mAuctionHomeLotinfo.setWidth(LotinfoArr.optJSONObject(i).getInt("width"));
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} 
			lotinfo.add(mAuctionHomeLotinfo);
		}
		
		JSONArray SpinfoArr = obj.optJSONArray("spinfo");
		for (int i = 0; i < SpinfoArr.length(); i++) {
			AuctionHomeSpinfo mAuctionHomeSpinfo = new AuctionHomeSpinfo();
			try {
				mAuctionHomeSpinfo.setImgurl(SpinfoArr.optJSONObject(i).getString("imgurl"));
				mAuctionHomeSpinfo.setSp_id(SpinfoArr.optJSONObject(i).getString("sp_id"));
				mAuctionHomeSpinfo.setTitle(SpinfoArr.optJSONObject(i).getString("title"));
				mAuctionHomeSpinfo.setWidth(SpinfoArr.optJSONObject(i).getInt("width"));
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} 
			spinfo.add(mAuctionHomeSpinfo);
		}
	}
	public List<AuctionHomeAdvs> getAdvs() {
		return advs;
	}
	public void setAdvs(List<AuctionHomeAdvs> advs) {
		this.advs = advs;
	}
	public List<AuctionHomeLotinfo> getLotinfo() {
		return lotinfo;
	}
	public void setLotinfo(List<AuctionHomeLotinfo> lotinfo) {
		this.lotinfo = lotinfo;
	}
	public List<AuctionHomeSpinfo> getSpinfo() {
		return spinfo;
	}
	public void setSpinfo(List<AuctionHomeSpinfo> spinfo) {
		this.spinfo = spinfo;
	}
	public AuctionHomeParser() {
		super();
	}
	public AuctionHomeParser(List<AuctionHomeAdvs> advs,
							 List<AuctionHomeLotinfo> lotinfo, List<AuctionHomeSpinfo> spinfo) {
		super();
		this.advs = advs;
		this.lotinfo = lotinfo;
		this.spinfo = spinfo;
	}
	
	@Override
	public String toString() {
		return "AuctionHomeParser [advs=" + advs + ", lotinfo=" + lotinfo
				+ ", spinfo=" + spinfo + "]";
	}

	public class AuctionHomeAdvs implements Serializable {
		private static final long serialVersionUID = 1L;
		private String linkurl;//链接地址
		private String type;//0：使用链接地址1：、拍卖2、专场3、拍品4、排行
		private String cat_id;//栏目推荐ID
		private String title;//标题
		private String info;//简介
		private String imgurl;//焦点图
		public String getLinkurl() {
			return linkurl;
		}
		public void setLinkurl(String linkurl) {
			this.linkurl = linkurl;
		}
		public String getType() {
			return type;
		}
		public void setType(String type) {
			this.type = type;
		}
		public String getCat_id() {
			return cat_id;
		}
		public void setCat_id(String cat_id) {
			this.cat_id = cat_id;
		}
		public String getTitle() {
			return title;
		}
		public void setTitle(String title) {
			this.title = title;
		}
		public String getInfo() {
			return info;
		}
		public void setInfo(String info) {
			this.info = info;
		}
		public String getImgurl() {
			return imgurl;
		}
		public void setImgurl(String imgurl) {
			this.imgurl = imgurl;
		}
		public AuctionHomeAdvs() {
			super();
		}
		public AuctionHomeAdvs(String linkurl, String type, String cat_id,
							   String title, String info, String imgurl) {
			super();
			this.linkurl = linkurl;
			this.type = type;
			this.cat_id = cat_id;
			this.title = title;
			this.info = info;
			this.imgurl = imgurl;
		}
		@Override
		public String toString() {
			return "AuctionHomeAdvs [linkurl=" + linkurl + ", type=" + type
					+ ", cat_id=" + cat_id + ", title=" + title + ", info="
					+ info + ", imgurl=" + imgurl + "]";
		}
	}
	public class AuctionHomeLotinfo implements Serializable {
		private static final long serialVersionUID = 1L;
		private int width;//宽度
		private String lot_id;//拍品id
		private String imgurl;//拍品图
		private String lot_name;//拍品名称
		private String is_record;//备案状态
		public int getWidth() {
			return width;
		}
		public void setWidth(int width) {
			this.width = width;
		}
		public String getLot_id() {
			return lot_id;
		}
		public void setLot_id(String lot_id) {
			this.lot_id = lot_id;
		}
		public String getImgurl() {
			return imgurl;
		}
		public void setImgurl(String imgurl) {
			this.imgurl = imgurl;
		}
		public String getLot_name() {
			return lot_name;
		}
		public void setLot_name(String lot_name) {
			this.lot_name = lot_name;
		}
		public String getIs_record() {
			return is_record;
		}
		public void setIs_record(String is_record) {
			this.is_record = is_record;
		}
		public AuctionHomeLotinfo() {
			super();
		}
		public AuctionHomeLotinfo(int width, String lot_id, String imgurl,
								  String lot_name, String is_record) {
			super();
			this.width = width;
			this.lot_id = lot_id;
			this.imgurl = imgurl;
			this.lot_name = lot_name;
			this.is_record = is_record;
		}
		@Override
		public String toString() {
			return "AuctionHomeLotinfo [width=" + width + ", lot_id=" + lot_id
					+ ", imgurl=" + imgurl + ", lot_name=" + lot_name
					+ ", is_record=" + is_record + "]";
		}
	}
	public class AuctionHomeSpinfo implements Serializable {
		private static final long serialVersionUID = 1L;
		private int width;//宽度
		private String sp_id;//专场id
		private String imgurl;//专场logo
		private String title;//专场名称
		public int getWidth() {
			return width;
		}
		public void setWidth(int width) {
			this.width = width;
		}
		public String getSp_id() {
			return sp_id;
		}
		public void setSp_id(String sp_id) {
			this.sp_id = sp_id;
		}
		public String getImgurl() {
			return imgurl;
		}
		public void setImgurl(String imgurl) {
			this.imgurl = imgurl;
		}
		public String getTitle() {
			return title;
		}
		public void setTitle(String title) {
			this.title = title;
		}
		public AuctionHomeSpinfo() {
			super();
		}
		public AuctionHomeSpinfo(int width, String sp_id, String imgurl,
								 String title) {
			super();
			this.width = width;
			this.sp_id = sp_id;
			this.imgurl = imgurl;
			this.title = title;
		}
		@Override
		public String toString() {
			return "AuctionHomeSpinfo [width=" + width + ", sp_id=" + sp_id
					+ ", imgurl=" + imgurl + ", title=" + title + "]";
		}
	}
}
